package com.song.quartz.controller;

import com.song.quartz.job.JobHandler;
import com.song.quartz.job.JobInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = {"定时任务"})
@RestController
public class QuartzController {
    @Autowired
    private JobHandler jobHandler;

    @ApiOperation(value = "增加任务", notes = "增加任务")
    @PostMapping("/addJob")
    public Object addJob(@RequestBody JobInfo jobInfo){
        jobHandler.addJob(jobInfo);
        return jobInfo;
    }

    @ApiOperation(value = "删除任务", notes = "删除任务")
    @PostMapping("/deleteJob")
    public Object deleteJob(@RequestBody JobInfo jobInfo){
        return jobHandler.deleteJob(jobInfo);
    }
}
